package cn.house.rent.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RentInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String requestURI = request.getRequestURI();
        if (requestURI.endsWith("")||requestURI.endsWith("")||requestURI.endsWith("")||requestURI.endsWith("")) {
            return true;
        }
        Object user = request.getSession().getAttribute("user");
        if (user != null){ //已经登录
            return true;
        } else { //未登录跳转登录界面
            response.sendRedirect(request.getContextPath()+"/jsp/login.jsp");
        }
        return false;
    }
}
